import sys
from django.core.management import base
from streamux.radio.management.commands import startdaemon
from streamux.radio.management.commands import stopdaemon

class Command(base.BaseCommand):
    can_import_settings = True
    help = 'Start the music processing daemon'

    def handle(self, *args, **kwargs):
        stopdaemon.stopdaemon()
        # Make sure stopdaemon finishes talking before we startdaemon.
        sys.stdout.flush()
        sys.stderr.flush()
        startdaemon.startdaemon()
